<%@ page pageEncoding="UTF-8"%>
<%@ page import="java.util.Map.Entry,java.util.*,java.util.regex.*,java.net.*,java.io.*,java.text.*"%>
<%@ page import="com.tianxiabuyi.*,com.tianxiabuyi.db.*,com.tianxiabuyi.model.*,com.tianxiabuyi.util.*"%>
<%@ page import="org.jsoup.Jsoup,org.jsoup.nodes.Element,org.jsoup.select.Elements"%>
<%@ page import="com.google.gson.reflect.TypeToken"%>
<%@ page import="org.dom4j.*"%>
<%!
	// 查询记录
	public List<? extends TXBYObject> queryItems(TXBYObject obj) {
		return QBuilder.db("basedb").queryHql("from " + obj.getClass().getSimpleName() + " where hospital = " + obj.getHospital() + " and status = " + STATUS_ENABLE + " order by cTime desc");
	}
	
	// 通过ID查询一条记录
	public TXBYObject queryItem(TXBYObject obj) {
		List<TXBYObject> list = QBuilder.db("basedb").queryHql("from " + obj.getClass().getSimpleName() + " where hospital = " + obj.getHospital() + " and id = " + obj.getId() + " and status = " + STATUS_ENABLE);
		return list.size() > 0 ? list.get(0) : null;
	}
	
	// 添加记录	
	public Integer createItem(TXBYObject obj) {
		return (Integer)DBTools.db("basedb").addItem(obj);
	} 
	 
	// 修改记录
	public boolean modifyItem(TXBYObject obj) {
		TXBYObject o = queryItem(obj);
		if (o == null) return false;
		DBTools.db("basedb").modItem(obj, obj.getId());
		return true;
	}
%>